<template>
  <article class="page">
    <headerbar>统计分析</headerbar>
    <section class="frame-content-sub no-bg">

      <section class="inner-content pdv-5 pdh-4" v-if="routeName == '1'">

        <section class="list-news-img bg-white">
          <section class="d-scroll-2head ">
            <cube-scroll
              ref="scroll"
              :options="options"
              @pulling-up="onPullingUp"
            >

              <section v-for="item in list" class="item">

                <div class="cont">
                  <div class="title"><span>用户：{{item.userName}}</span><span>得分：{{item.score}}分</span></div>
                  <div class="tip">
                    <span class="one">{{item.institutionsName}}</span>
                  </div>
                  <div class="tip">
                    <span class="one">评分时间：{{getTime(item.createTime)}}</span>
                  </div>
                </div>

              </section>
              <div class="text-center no-data" v-if="list.length===0">
                <img src="../../../../static/images/no_data.png" alt="">
                <p>暂无数据</p>
              </div>
            </cube-scroll>
          </section>
        </section>

      </section>
      <section class="inner-content pdv-5 pdh-4" v-if="routeName == '2'">

        <section class="list-news-img bg-white">
          <section class="d-scroll-2head ">
            <cube-scroll
              ref="scroll"
              :options="options"
              @pulling-up="onPullingUp"
            >

              <section v-for="item in list" class="item">
                <div class="cont">
                  <div class="title"><span>{{item.userName}}</span><span>得分：{{item.score}}分</span></div>
                  <div class="tip">
                    <span class="one">是否党员：{{item.sfdy==='1'?'是':'不是'}}</span>
                  </div>
                  <div class="tip">
                    <span class="one">培训机构名称：{{item.institutionsName}}</span>
                  </div>
                  <div class="tip">
                    <span class="one">评分时间：{{getTime(item.createTime)}}</span>
                  </div>
                </div>

              </section>
              <div class="text-center no-data" v-if="list.length===0">
                <img src="../../../../static/images/no_data.png" alt="">
                <p>暂无数据</p>
              </div>
            </cube-scroll>
          </section>
        </section>

      </section>
      <section class="inner-content pdv-5 pdh-4" v-if="routeName == '3'">

        <section class="list-news-img bg-white">
          <section class="d-scroll-2head ">
            <cube-scroll
              ref="scroll"
              :options="options"
              @pulling-up="onPullingUp"
            >

              <section v-for="item in list" class="item">
                <div class="cont">
                  <div class="title"><span>讲师名称：{{item.lecturerName}}</span><span>得分：{{item.score}}分</span></div>
                  <div class="tip">
                    <span class="one">课程名称：{{item.curriculumName}}</span>
                  </div>
                  <div class="tip">
                    <span class="one">用户名称：{{item.userName}}</span>
                  </div>
                  <div class="tip">
                    <span class="one">评分时间：{{getTime(item.createTime)}}</span>
                  </div>
                </div>

              </section>

              <div class="text-center no-data" v-if="list.length===0">
                <img src="../../../../static/images/no_data.png" alt="">
                <p>暂无数据</p>
              </div>

            </cube-scroll>
          </section>
        </section>

      </section>
      <section class="inner-content pdv-5 pdh-4" v-if="routeName == '4'">

        <section class="list-news-img bg-white">
          <section class="d-scroll-2head ">
            <cube-scroll
              ref="scroll"
              :options="options"
              @pulling-up="onPullingUp"
            >

              <section v-for="item in list" class="item">

                <div class="cont">
                  <div class="title"><span>主办单位：{{item.zbdwName}}</span><span>得分：{{item.score}}分</span></div>
                  <div class="tip">
                    <span class="one">用户名称：{{item.userName}}</span>
                  </div>
                  <div class="tip">
                    <span class="one">评分时间：{{getTime(item.createTime)}}</span>
                  </div>
                </div>

              </section>

              <div class="text-center no-data" v-if="list.length===0">
                <img src="../../../../static/images/no_data.png" alt="">
                <p>暂无数据</p>
              </div>

            </cube-scroll>
          </section>
        </section>

      </section>

    </section>
  </article>
</template>

<script>
  import moment from 'moment'

  export default {
    name: 'appraiseManage',
    data () {
      return {
        routeName: '1',
        pageIndex: 1,
        pageSize: 10,
        list: [],
        options: {
          pullUpLoad: true,
          scrollbar: false
        },
        statisticalAnalysisDetail: {}
      }
    },
    created () {
      this.routeName = this.$route.query.index || '1'
      this.statisticalAnalysisDetail = this.$store.statisticalAnalysisDetail
      this.trainingplanpjList(this.routeName)
    },
    methods: {
      trainingplanpjList (index) {
        // 类型(1学员对培训机构的评价 2学员对主办单位的评价 3学员对讲师及讲授课程的评价 4培训机构对学员的评价 5主办单位对学员的评价)
        index = index || '1'
        let query = this.$route.query
        let params = {
          'type': query.index,
          'limit': this.pageSize,
          'page': this.pageIndex
        }
        if (index === '1') {
          params.institutionsId = this.statisticalAnalysisDetail.institutionsId
        } else if (index === '2') {
          params.userId = this.statisticalAnalysisDetail.userId
          params.type = '4'
        } else if (index === '3') {
          params.lecturerId = this.statisticalAnalysisDetail.lecturerId
        } else if (index === '4') {
          params.type = '2'
          params.zbdwId = this.statisticalAnalysisDetail.zbdwId
        }
        return this.fetchService.trainingplanpjList(params).then(res => {
          if (res.code !== 0) {
            this.$refs.scroll.forceUpdate && this.$refs.scroll.forceUpdate()
            return this.tools.tip(res.message)
          }
          this.pageIndex ++
          this.list = this.list.concat(res.data)
          setTimeout(() => {
            this.$refs.scroll.forceUpdate && this.$refs.scroll.forceUpdate(true, false)
            this.options.pullUpLoad = false
          }, 100)
          return res
        })
      },
      onPullingUp () {
        this.trainingplanpjList(this.routeName)
      },
      getTime (createTime) {
        return moment(createTime).format('YYYY年MM月DD日')
      }
    }
  }
</script>

<style scoped lang="scss">
  .list-news-img .item .cont .title {
    min-height:0;
    display:flex;
    justify-content:space-between;
  }
</style>
